#include<iostream>
#include<queue>

using namespace std;

const int N = 1010;
queue<int>q;
int n , m;
int cnt;//次数
bool st[N];//标记是否存了
int main()
{
    cin >> m >> n;
    for(int i = 1;i <= n;i ++)
    {
        int x; cin >> x;
        if(st[x]) continue;
        q.push(x);
        cnt++;
        st[x] = true;
        if(q.size() > m)
        {
            st[q.front()] = false;
            q.pop();
        }
    }
    cout << cnt << endl;
    return 0;
}